package com.cqw.commontest.mongodb.dao;

import com.cqw.commontest.mongodb.pojo.User;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.mongodb.repository.MongoRepository;

import java.util.List;

/**
 * 继承 MongoRepository 指定实体类与主键类型
 *
 * @Author: caoqingwen
 * @CreateTime: 2021-08-04 23:52
 * @Description:
 */
public interface UserRepository extends MongoRepository<User, String> {


    /**
     * 根据state和sex查询
     *
     * @param state
     * @param sex
     * @return
     */
    List<User> findByStateAndSex(Integer state, Integer sex);


    /**
     * 根据年龄分页查询
     *
     * @param age
     * @param pageable
     * @return
     */
    Page<User> findByAge(Integer age, Pageable pageable);


    /**
     * 根据state和age查询用户
     *
     * @param state
     * @param age
     * @return
     */
//    @Query()
//    List<User> selectEnableUserByAge(Integer state, Integer age);

}
